package com.bafa.front.events;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bafa.objects.PageBean;
import com.bafa.objects.season.RoundMatch;
import com.bafa.services.FixtureServices;

public class AddRoundEvent extends Event{

	public void doEvent(HttpServletRequest request, HttpServletResponse response, PageBean page) {
		int roundId = new Integer(request.getParameter("roundId")).intValue();
		boolean previousGroup = (request.getParameter("previous").equals("GROUP"));
		boolean cup = (request.getParameter("cup").equals("CUP"));
		int previousIdA = new Integer(request.getParameter("previousIdA")).intValue();
		int previousIdB = new Integer(request.getParameter("previousIdB")).intValue();
		int previousPositionA = new Integer(request.getParameter("previousPositionA")).intValue();
		int previousPositionB = new Integer(request.getParameter("previousPositionB")).intValue();
		
		int day = new Integer(request.getParameter("day")).intValue();
		int month = new Integer(request.getParameter("month")).intValue();
		int year = new Integer(request.getParameter("year")).intValue();
		int seasonId = new Integer(request.getParameter("seasonId")).intValue();
		int hour = new Integer(request.getParameter("hour")).intValue();
		int minute = new Integer(request.getParameter("minute")).intValue();
		String roundName ="";
		RoundMatch roundMatch = new RoundMatch();
		roundMatch.setPreviousGroupA(previousGroup);
		roundMatch.setPreviousGroupB(previousGroup);
		roundMatch.setPreviousIdA(previousIdA);
		roundMatch.setPreviousIdB(previousIdB);
		if(previousGroup){
			roundMatch.setPreviousPositionA(previousPositionA);
			roundMatch.setPreviousPositionB(previousPositionB);
		}
		
		
		
		FixtureServices.addRound(roundMatch,day,month,year,hour,minute,seasonId,true,roundName,cup,roundId);
		
	}

}
